package com.oil.petro.eshop.entity;

import com.oil.petro.eshop.bean.ProductBean;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "product")
public class Product implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    int id;
    @Column(name = "name")
    String name;
    @Column(name = "description")
    String description;
    @Column(name = "cost")
    float cost;
    @Column(name = "amount")
    int amount;
    @Column(name = "manufacturer_id")
    int manufacturerId;
    @Column(name = "category_id")
    int categoryId;
    @Column(name = "order_status")
    int orderStatus;
    @Lob
    @Column(name = "image", length = 1 * 1024 * 1024)
    String image;

////    @ManyToMany(mappedBy = "products")
////    private Set<Account> accounts = new HashSet<Account>();
//
////    @OneToMany(mappedBy = "product")
////    @LazyCollection(LazyCollectionOption.FALSE)
////    private Set<Cart> cart = new HashSet<Cart>();
//////       @Transient
//////    @OneToMany( mappedBy = "pk.product")
//////              @LazyCollection(LazyCollectionOption.FALSE)
//////Set<AccountProduct> accountProduct = new HashSet<AccountProduct>();
//////
//////    public Set<AccountProduct> getAccountProduct() {
//////        return accountProduct;
//////    }
//////
//////    public void setAccountProduct(Set<AccountProduct> accountProduct) {
//////        this.accountProduct = accountProduct;
//////    }

   

    

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public float getCost() {
        return cost;
    }

    public void setCost(float cost) {
        this.cost = cost;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public int getManufacturerId() {
        return manufacturerId;
    }

    public void setManufacturerId(int manufacturerId) {
        this.manufacturerId = manufacturerId;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(int orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Override
    public String toString() {
        return "Product{" + "id=" + id + ", name=" + name + ", description=" + description + ", cost=" + cost + ", amount=" + amount + ", manufacturerId=" + manufacturerId + ", categoryId=" + categoryId + ", orderStatus=" + orderStatus + ", image=" + image + '}';
    }

//    public Set<Account> getAccounts() {
//        return accounts;
//    }
//
//    public void setAccounts(Set<Account> accounts) {
//        this.accounts = accounts;
//    }
//
//    public Set<Cart> getCart() {
//        return cart;
//    }
//
//    public void setCart(Set<Cart> cart) {
//        this.cart = cart;
//    }

////    public void addCart(Cart cart,ProductBean productBean,Set<Cart> carts) {
////        
////        
////        
//////        if(carts.contains(cart)){
//////        System.out.println("AAAAAAAAAAAAAAAAAAQQQQQQ");
//////        cart.setOrderedQuantity(productBean.getOrderedQuantity());
//////        for(Cart item:carts){
//////        if(item.equals(cart)){
//////        cart.setOrderedQuantity(item.getOrderedQuantity()+cart.getOrderedQuantity());
//////            
//////            //item=cart;
//////            
//////            carts.remove(item);
//////            this.cart.add(cart);
//////                System.out.println("BBBBBBBBBBBBBBB");
//////
//////        }
//////        
//////        }
//////        }else
////        this.cart.add(cart);
////    }
    
    //will be changed
//    public Cart getCart2 (int accountId) {
//    
//       
//        
//        for(Cart cart2 :cart){
//        
//            if(cart2.getAccount().getId()==accountId&&cart2.getProduct().getId()==this.id) {
//            
//            return cart2;
//            }
//            
//        } 
        
        
//    return null;
//    
//    }
}
